<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/14
 * Time: 16:50
 */

namespace Admin\Controller;


class OrderController extends AdminController
{
    public function _initialize(){
        parent::_initialize();
    }

    public function index(){
        $where=array();
        $uid=session('user_auth.uid');
        //审核权限
        if($uid!=1){
            $grout_id=M('auth_group_access')->where(array('uid'=>$uid))->find();
            if($grout_id['group_id']==10){
                $shop_info=M('member')->where(array('uid'=>$grout_id['uid']))->find();
                $where['id']=$shop_info['shop_id'];
            }
        }
        $listsCount = M('order')->where($where)->count();
        $Page       = new \Think\Page($listsCount,10);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show       = $Page->show();// 分页显示输出
        $lists = M('order')->where($where)->order(' check_status asc,id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
        foreach ($lists as $ke=>$ve){
            $lists[$ke]['shop_area']=detail_area_name($ve['shop_area']);
        }
        $this->assign('list',$lists);
        $this->assign('group_id',$grout_id['group_id']);
        $this->assign('_page',$show);
        $this->display();
    }
    function createSn(){
        return date('YmdHis').mt_rand(10,99).$this->generate_password(2,'8713425069');
    }
    function generate_password( $length = 8 ,$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') {
        $password = '';
        for ( $i = 0; $i < $length; $i++ )
        {
            // 这里提供两种字符获取方式
            // 第一种是使用 substr 截取$chars中的任意一位字符；
            // 第二种是取字符数组 $chars 的任意元素
            // $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
            $password .= $chars[ mt_rand(0, strlen($chars) - 1) ];
        }
        return $password;
    }
}